/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.ces4.produccion.jpa.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.PostLoad;
import javax.persistence.Table;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "tpdr_articulo")
@NamedQueries({
    @NamedQuery(name = "Articulo.findAll", query = "SELECT a FROM Articulo a")})
public class Articulo implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "DSID", nullable = false, length = 20)
    private String dsid;
    @Basic(optional = false)
    @Column(name = "DSDESCRIPCION", nullable = false, length = 50)
    private String dsdescripcion;
    @Basic(optional = false)
    @Column(name = "NMDURACION", nullable = false)
    private int nmduracion;
    @Basic(optional = false)
    @Column(name = "SNESTADO", nullable = false)
    private boolean snestado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo", fetch = FetchType.LAZY)
    private List<ArticuloLinea> articuloLineaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo", fetch = FetchType.LAZY)
    private List<MateriaPrimaArticulo> materiaPrimaArticuloList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo", fetch = FetchType.LAZY)
    private List<DetalleSolicitudProduccion> detalleSolicitudProduccionList;

    public Articulo() {
    }

    public Articulo(String dsid) {
        this.dsid = dsid;
    }

    public Articulo(String dsid, String dsdescripcion, int nmduracion) {
        this.dsid = dsid;
        this.dsdescripcion = dsdescripcion;
        this.nmduracion = nmduracion;
    }

    public String getDsid() {
        return dsid;
    }

    public void setDsid(String dsid) {
        this.dsid = dsid;
    }

    public String getDsdescripcion() {
        return dsdescripcion;
    }

    public void setDsdescripcion(String dsdescripcion) {
        this.dsdescripcion = dsdescripcion;
    }

    public int getNmduracion() {
        return nmduracion;
    }

    public void setNmduracion(int nmduracion) {
        this.nmduracion = nmduracion;
    }

    public boolean getSnestado() {
        return snestado;
    }

    public void setSnestado(boolean snestado) {
        this.snestado = snestado;
    }

    public List<ArticuloLinea> getArticuloLineaList() {
        return articuloLineaList;
    }

    public void setArticuloLineaList(List<ArticuloLinea> articuloLineaList) {
        this.articuloLineaList = articuloLineaList;
    }

    public List<MateriaPrimaArticulo> getMateriaPrimaArticuloList() {
        return materiaPrimaArticuloList;
    }

    public void setMateriaPrimaArticuloList(List<MateriaPrimaArticulo> materiaPrimaArticuloList) {
        this.materiaPrimaArticuloList = materiaPrimaArticuloList;
    }

    public List<DetalleSolicitudProduccion> getDetalleSolicitudProduccionList() {
        return detalleSolicitudProduccionList;
    }

    public void setDetalleSolicitudProduccionList(List<DetalleSolicitudProduccion> detalleSolicitudProduccionList) {
        this.detalleSolicitudProduccionList = detalleSolicitudProduccionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dsid != null ? dsid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Articulo)) {
            return false;
        }
        Articulo other = (Articulo) object;
        if ((this.dsid == null && other.dsid != null) || (this.dsid != null && !this.dsid.equals(other.dsid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.com.ces4.produccion.jpa.entities.Articulo[ dsid=" + dsid + " ]";
    }

    @PostLoad
    public void fixIt() {
        this.articuloLineaList = new ArrayList<ArticuloLinea>(this.articuloLineaList);
        this.materiaPrimaArticuloList = new ArrayList<MateriaPrimaArticulo>(this.materiaPrimaArticuloList);
        this.detalleSolicitudProduccionList = new ArrayList<DetalleSolicitudProduccion>(this.detalleSolicitudProduccionList);
    }
}
